package com.hsjk.szwj.module.train.controller.admin;

import com.hsjk.szwj.framework.common.pojo.CommonResult;
import com.hsjk.szwj.framework.common.pojo.PageResult;
import com.hsjk.szwj.module.train.controller.admin.vo.*;
import com.hsjk.szwj.module.train.dal.dataobject.employee.EmployeeDO;
import com.hsjk.szwj.module.train.service.ICourseService;
import com.hsjk.szwj.module.train.service.IEmployeeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

import static com.hsjk.szwj.framework.common.pojo.CommonResult.success;

/**
 * @author chenjiawei
 * @desc
 * @Date 2023/08/04 00:52
 **/
@Tag(name = "后台管理端 - 员工相关接口")
@RestController
@RequestMapping("/train/employee")
@Validated
public class AdminEmployeeController {

    @Resource
    private IEmployeeService employeeService;

    @PostMapping("/page-employee")
    @Operation(summary = "获取员工分页列表")
    public CommonResult<PageResult<EmployeeDO>> getAdminEmployeePage(@RequestBody @Valid AdminEmployeePageReqVO reqVO) {
        return success(employeeService.getEmployeePage(reqVO));
    }


    @PostMapping("/create")
    @Operation(summary = "创建员工")
    public CommonResult<Boolean> createModuleEmployee(@RequestBody @Valid EmployeeDO employeeDO) {
        return success(employeeService.createModuleEmployee(employeeDO));
    }

    @GetMapping("/get-employee-by-id")
    @Operation(summary = "获取员工详情")
    public CommonResult<EmployeeDO> getAdminEmployeeDetail(@RequestParam Long id) {
        return success(employeeService.getAdminEmployeeDetail(id));
    }

    @PostMapping("/update")
    @Operation(summary = "更新员工")
    public CommonResult<Boolean> updateModuleEmployee(@RequestBody @Valid EmployeeDO reqVO) {
        return success(employeeService.updateModuleEmployee(reqVO));
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除员工")
    public CommonResult<Boolean> deleteModuleEmployee(@RequestParam("id") Long id) {
        return success(employeeService.deleteModuleEmployee(id));
    }



}
